﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ModuleBase
{
    public static class MyFunc
    {
        public static string MessageStr = string.Empty;
        public static void AddMessage(string message)
        {
            object _lockObj = new object();
            lock (_lockObj)
            {
                var formattedMessage = $"{DateTime.Now:HH:mm:ss} {message}";

                var lines = MessageStr.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                if (lines.Length >= 1000)
                {
                    MessageStr = string.Empty;
                }
                if (!string.IsNullOrEmpty(MessageStr))
                {
                    MessageStr += "\n";
                }
                MessageStr += formattedMessage;
            }
        }
    }
}
